package cn.tedu.yl.cost.service.impl;


import cn.tedu.yl.cost.mapper.CostMapper;
import cn.tedu.yl.cost.pojo.dto.CostQuery;
import cn.tedu.yl.cost.pojo.dto.CostSaveParam;
import cn.tedu.yl.cost.pojo.entity.Cost;
import cn.tedu.yl.cost.pojo.vo.CostVO;
import cn.tedu.yl.cost.service.CostService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public class CostServiceImpl implements CostService {
    @Autowired
    private CostMapper costMapper;

    @Override
    public List<CostVO> select(CostQuery costQuery) {
        return costMapper.select(costQuery);
    }

    @Override
    public void save(CostSaveParam costSaveParam) {
        Cost cost=new Cost();
        BeanUtils.copyProperties(costSaveParam,cost);
        if (cost.getId()==null){
            costMapper.insertCost(cost);
        }
        else {
            costMapper.updateCost(cost);
        }
    }
}
